package org.njyinghuo.sdk.bytedance.client.douyin;

import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import org.njyinghuo.sdk.bytedance.conf.Config;

import java.io.File;

/**
 * @description:
 * @author: Hupengpeng
 * @time: 2021/7/5 9:05
 */
public class VideoPartUpload {
    private String open_id;
    private String access_token;
    private String upload_id;
    private int part_number;
    private String response;
    private File video;

    private VideoPartUpload() {
    }

    protected static VideoPartUpload New() {
        return new VideoPartUpload();
    }

    public VideoPartUpload execute() {
        String url = StrUtil.format("{}{}?open_id={}&access_token={}&upload_id=?&part_number={}",
                Config.API_HTTP_SCHEME + Config.API_HOST,
                Config.API_VIDEO_UPLOAD_PART_UPLOAD,
                getOpen_id(),
                getAccess_token(),
                getUpload_id(),
                getPart_number());
        HttpResponse rs = HttpUtil.createPost(url).form("video", getVideo()).execute();
        response = rs.body();
        return this;
    }

    public String getOpen_id() {
        return open_id;
    }

    public VideoPartUpload setOpen_id(String open_id) {
        this.open_id = open_id;
        return this;
    }

    public String getAccess_token() {
        return access_token;
    }

    public VideoPartUpload setAccess_token(String access_token) {
        this.access_token = access_token;
        return this;
    }

    public String getUpload_id() {
        return upload_id;
    }

    public VideoPartUpload setUpload_id(String upload_id) {
        this.upload_id = upload_id;
        return this;
    }

    public int getPart_number() {
        return part_number;
    }

    public VideoPartUpload setPart_number(int part_number) {
        this.part_number = part_number;
        return this;
    }

    public String getResponse() {
        return response;
    }

    public VideoPartUpload setResponse(String response) {
        this.response = response;
        return this;
    }

    public File getVideo() {
        return video;
    }

    public VideoPartUpload setVideo(File video) {
        this.video = video;
        return this;
    }
}
